package com.en.config;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;

import javax.annotation.PostConstruct;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * ClassName: WxPayConfig
 * Package: com.question.config
 * Description:
 *
 * @Date: 2023/12/29 23:14
 * @Author: wht
 */
@Configuration
public class GlobalConfig {
    @Autowired // 注入 ResourceLoader 对象
    private ResourceLoader resourceLoader;

    public static String nginxRootPath = "http://39.105.216.113:8080";
    public static String speechWordUsRootPath = "/app/nginx/www/speech_word_us";
    public static String speechWordUkRootPath = "/app/nginx/www/speech_word_uk";
    public static String speechWordZhRootPath = "/app/nginx/www/speech_word_zh";
    public static String speechSentenceUsRootPath = "/app/nginx/www/speech_sentence_us";
    public static String speechSentenceZhRootPath = "/app/nginx/www/speech_sentence_zh";


    //    电脑上测试--------------------------------
//    public static String speechWordUsRootPath = "/Users/wuhaitao/Desktop/us/";
//    public static String speechWordZhRootPath = "/Users/wuhaitao/Desktop/zh/";


    public static String SecretId;
    public static String SecretKey;
    public static String Region;
    public static String BucketName;
    public static String Version;
    public static String Uid;
    public static String Action;
    public static String GetObject;
    public static String Path;


    @PostConstruct
    public void getWxPayConfig() throws IOException {
        // 获取properties文件里的敏感数据--------------------
        Properties properties = new Properties();
        Resource resource = resourceLoader.getResource("classpath:GlobalConfig.properties");
        InputStream inputStream = resource.getInputStream();
        properties.load(inputStream);


        SecretId = properties.getProperty("SecretId");
        SecretKey = properties.getProperty("SecretKey");
        Region = properties.getProperty("Region");
        BucketName = properties.getProperty("BucketName");
        Version = properties.getProperty("Version");
        Uid = properties.getProperty("Uid");
        Action = properties.getProperty("Action");
        GetObject = properties.getProperty("GetObject");
        Path = properties.getProperty("Path");
    }
}
